var SPSdk = (function () {

    function SPSdk() {
        this.rewardedVideoAd = null;
        this.ADObj = {};
        this.reportedGameDataCache = {};
		this.localData = {};
    }

    var __proto = SPSdk.prototype;
    __proto.init  = function(param, callback){
        console.log("模版初始化：" + JSON.stringify(param));
        this.gameId = param.appId;
        callback && callback({"result": 0, "desc": "OK"});
        var _localData = window.localStorage.getItem("sudo_remoteData");
		if(_localData == null||_localData == "") _localData="{}";
		this.localData = JSON.parse(_localData);
		setTimeout(function(){ 
			if(_localData){
				for(var key in this.localData){
					StorageVariable.INSTANT.addProp(key,this.localData[key]);
				}
			}
		}, 1000);
		
    }

    __proto.login = function(param, callback){
		var data = {};
		data.result  = 0;
		data.desc = "ok";
		this.userOpenId = "testOpenId";
		callback && callback(data);
    }
	
	__proto.setUserData = function(key,value,caller,callback){
		this.localData[key] = value;
		if( window.localStorage){
			window.localStorage.setItem("sudo_remoteData",JSON.stringify(this.localData));
		}
		callback && callback.call(caller,{result: 0, desc: "ok"});		      
	}
	__proto.getUserData = function(key,caller,callback){
		var _data = this.localData?this.localData[key]:null;
		callback && callback.call(caller,{result: 0, key:key,data:_data,desc: "ok"});
	}
    __proto.getUserOpenId = function() {
        return this.userOpenId || '';
    }
    //显示奖励式视频广告
    __proto.showRewardVideo = function(adUnitId, callback) {
        callback && callback({result : 0, desc:"ok" });
    };


    //显示横幅广告
    __proto.showBannerAD = function(adUnitId, style, forceCreate, callback) {
        callback && callback({result: 0});
    };

    //隐藏横幅广告
    __proto.hideBannerAD = function(adUnitId, callback) {
    };
    

    //获取微信上报数据
    __proto.getGameData = function(_keyList, callback) {
        callback && callback({result : 0, data : ""});
    };

    // 获取自己的用户信息
    __proto.getUserInfo = function( callback) {
		callback && callback({result:0, data:{
				nickName : "test",
				avatarUrl : "test",
				avatarBase64 : ""
			}});        
    };

    //获取当前用户微信上报数据
    __proto.getSelfGameData = function(_keyList, callback) {
       callback && callback({result :0, data : ""});
    };

    //微信数据上报
    __proto.reportedGameData = function(key, value, callback) {
        callback && callback({result : 0});
    };

    //微信 主域向子域发消息
    __proto.postMessage = function(data) {
    };
	__proto.sendEventStatistics = function (name, data){
		if(wx.aldSendEvent)
			wx.aldSendEvent(name,{param:data});
	}
    //微信 子域监听主域发消息
    __proto.onMessage = function(callback) {
    };

    //分享
    __proto.share = function(param, callback) {        
		var _result={result:0};
		_result.state = 0;
		_result.data = "";
		callback && callback(_result);        
    };

    //微信默认转发配置
    __proto.initShareInfo = function(param, callback) {
        callback && callback({result:0});
    };


    __proto.showGameClubButton = function(style){
    }

    __proto.hideGameClubButton = function(){
    }
    return SPSdk;
})();
window.SPSDK = new SPSdk;
//module && (module.exports = new SPSdk());